//
//  LazyController.swift
//  one
//
//  Created by huangfeng on 2018/5/6.
//  Copyright © 2018年 huangfeng. All rights reserved.
//

import UIKit

class LazyController: UIViewController {

    
    lazy var demol: DemoLabel = DemoLabel()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        setupUI()
        
        
        let person = LPerson()
        person.name = "张三"
        
        let label = DemoLabel(frame: CGRect(x: 20, y: 100, width: 200, height: 30))
        
        view.addSubview(label)
        label.person = person
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        
    }
    
    private func setupUI() {
        view.addSubview(demol)
        demol.text = "hello"
        demol.sizeToFit()
        demol.center = view.center
        
        let onebtn = UIButton(frame: CGRect(x: 20, y: 20, width: 100, height: 30))
        onebtn.addTarget(self, action: #selector(clickMe(btn:)), for: .touchUpInside)
        onebtn.setTitle("返回", for: .normal)
        onebtn.setTitleColor(#colorLiteral(red: 0.9372549057, green: 0.3490196168, blue: 0.1921568662, alpha: 1), for: .normal)
        onebtn.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        onebtn.layer.cornerRadius = 5
        onebtn.layer.shadowOffset = CGSize(width: 100, height: 20)
        onebtn.layer.shadowColor = UIColor.black.cgColor
        view.addSubview(onebtn)
        
        
        
        
    }
    
    @objc private func clickMe(btn:UIButton) {
        self.dismiss(animated: true, completion: nil)
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
